<div class="sidebar-wrapper">
  {{ $currentPage := . }}
  <nav role="navigation" class="sidebar">
    <ul>
      <div id="docsearch"></div>
      {{ range .Site.Menus.main.ByWeight }}
      <li class="level-1">
        <a class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
          {{.Name | markdownify}}
        </a>

        {{- if .HasChildren }}
        <ul>
          {{- range .Children }}
          <li class="level-2 {{if .HasChildren }}has-children{{ else }}no-children{{ end }}">
            <a {{with .URL}}href="{{.}}"{{end}} class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
              {{- if .HasChildren }}
                {{ readFile "static/images/icon_sidebar_expander.svg" | safeHTML }}
              {{ end }}
              {{.Name | markdownify}}
            </a>

            {{- if .HasChildren }}
            <ul>
              {{- range .Children }}
              <li class="level-3">
                <a href="{{.URL}}" class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
                  {{.Name | markdownify}}
                </a>
              </li>
              {{- end}}
            </ul>
            {{- end}}
          </li>
          {{- end}}
        </ul>
        {{- end}}
      </li>
      {{- end}}
    </ul>
  </nav>
</div>
